<template>
	<view>
		<view class="pl-30 pr-30 pt-30" v-for="(item, index) in resumeLists" :key="index"
			@click="$goRoute.goUrl('/pages/lists/info?id='+item.id)">
			<view class="bg-white pl-30 pr-30 pt-20 pb-20 border-radius">
				<view class="flex space-between items-center mt-10">
					<view class="flex items-center" @click="$goRoute.goUrl('/pages/lists/info?id='+item.id)">
						<image src="../../../static/images/avatar.png" mode=""
							style="width: 70rpx;height: 70rpx;border-radius: 50%;"></image>
						<view class=" ml-20">
							<view class="font-28">{{item.username}}</view>
							<view class="font-22 mt-10 font-grey">{{calculateAge(item.birthday)}}岁 |
								{{calculateAge(item.workTime)}}年
							</view>
						</view>
					</view>
					<view class="font-24 font-g border-g border-radius pt-10 pb-10 pl-20 pr-20">打招呼</view>
				</view>
				<view class="flex items-center mt-20" @click="$goRoute.goUrl('/pages/lists/info?id='+item.id)">
					<uni-icons custom-prefix="iconfont" type="icon-aixin_shixin" size="16" color="#46B4B1"></uni-icons>
					<view class="font-24 ml-20">期望：<text v-for="(itd, idx) in item.zbApplyintentionList"
							:key="idx">{{itd.expectPosition}}</text></view>
				</view>
				<view class="flex items-center mt-20" @click="$goRoute.goUrl('/pages/lists/info?id='+item.id)">
					<uni-icons custom-prefix="iconfont" type="icon-gongzuoxinxi" size="16" color="#46B4B1"></uni-icons>
					<view class="font-24 ml-20">{{item.zbApplyworkList[0].companyName}} ·
						{{item.zbApplyworkList[0].position}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		list as resumeList
	} from '../../../api/apply_user.js'
	export default {
		data() {
			return {
				height: 0,
				statusBarHeight: 0,
				navBarHeight: 0,
				searchWords: '',
				selectIndex: 0,
				array: ['东营区', '河口区', '利津县', '广饶县'],
				index: 0,
				pageNo: 1,
				pageSize: 10,
				resumeLists: [],
			};
		},
		onLoad() {
			this.getHeight()
			this.getResumeList()
		},
		methods: {
			getResumeList() {
				uni.showLoading({
					title: '加载中'
				})
				resumeList({
					pageSize: this.pageSize,
					pageNo: this.pageNo,
				}).then(res => {
					if (this.pageNo === 1) {
						this.resumeLists = res.result.records
					} else {
						this.resumeLists.push(...res.result.records)
					}
					this.pageNo += 1
					uni.hideLoading()
				})
			},
			bindPickerChange: function(e) {
				this.index = e.detail.value
				this.search()
			},
			search() {
				uni.showLoading({
					title: '加载中...'
				})
				setTimeout(() => {
					uni.hideLoading()
				}, 1000)
			},
			setIndex(index) {
				this.selectIndex = index
				this.search()
			},
			//获取屏幕导航栏高度
			getHeight() {
				if (wx.canIUse('getMenuButtonBoundingClientRect')) {
					let sysInfo = wx.getSystemInfoSync(); //状态栏的高度
					this.statusBarHeight = sysInfo.statusBarHeight;
					// 胶囊位置信息
					let rect = wx.getMenuButtonBoundingClientRect();
					this.menuButtonRect = JSON.parse(JSON.stringify(rect));
					// 导航栏高度
					let navBarHeight = (rect.top - sysInfo.statusBarHeight) * 2 + rect.height;
					this.navBarHeight = navBarHeight;
					// 自定义导航栏的高度
					this.height = sysInfo.statusBarHeight + navBarHeight;
				} else {
					wx.showToast({
						title: '您的微信版本过低，界面可能会显示不正常',
						icon: 'none',
						duration: 4000
					});
				}
			},
			calculateAge(birthdate) {
				var today = new Date();
				var birthDate = new Date(birthdate);
				var age = today.getFullYear() - birthDate.getFullYear();
				var monthDiff = today.getMonth() - birthDate.getMonth();
			
				if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
					age--;
				}
			
				return age;
			},
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F6F6F6;
	}

	.nav-box {
		background-color: #46b4b1;
		position: sticky;
		top: 0;
		z-index: 9999;

		.search-input {
			background-color: rgba(255, 255, 255, .8);
			height: 30px;
			display: flex;
			align-items: center;
			border-radius: 50rpx;
			padding: 0 30rpx;
		}
	}

	.list-bord {
		background: #fff;
		width: 68rpx;
		height: 8rpx;
	}
</style>